/*
 * Copyright 2009 Millibit Systems.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
 * either express or implied. See the License for the specific language
 * governing permissions and limitations under the License.
 */
package jp.millibit.core
{

	/**
	 * 前提条件の検証を行います。
	 *
	 * @param cond 前提条件の評価結果
	 * @param message エラーメッセージ
	 * @throws Error 前提条件を満たさない場合(<code>false</code>の値が<code>false</code>の場合)
	 *
	 * @example 仮引数が<code>null</code>を許可しない場合
	 * <pre>
	 * private function test(arg0:String):void{
	 *  assert(arg0 != null, "arg0はnullを許可しません。");
	 *  trace(arg0);
	 * }
	 * </pre>
	 */
	public function assert(cond:Boolean, message:String = null):void
	{
		if (!cond)
		{
			throw new AssertError(message);
		}
	}
}

class AssertError extends Error
{

	public function AssertError(message:String)
	{
		super(message ? message : "");
	}
}
